package cn.iocoder.yudao.module.wine.dal.mysql.businesscredit;

import java.math.BigDecimal;
import java.util.*;

import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.MPJLambdaWrapperX;
import cn.iocoder.yudao.module.wine.controller.app.businesscredit.vo.AppBusinessCreditRespVO;
import cn.iocoder.yudao.module.wine.dal.dataobject.businesscredit.BusinessCreditDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.wine.controller.admin.businesscredit.vo.*;

/**
 * 会员等级管理 Mapper
 *
 * @author 管理员
 */
@Mapper
public interface BusinessCreditMapper extends BaseMapperX<BusinessCreditDO> {

    default PageResult<BusinessCreditDO> selectPage(BusinessCreditPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<BusinessCreditDO>()
                .likeIfPresent(BusinessCreditDO::getName, reqVO.getName())
                .eqIfPresent(BusinessCreditDO::getLevel, reqVO.getLevel())
                .eqIfPresent(BusinessCreditDO::getExperience, reqVO.getExperience())
                .eqIfPresent(BusinessCreditDO::getIcon, reqVO.getIcon())
                .eqIfPresent(BusinessCreditDO::getBackgroundUrl, reqVO.getBackgroundUrl())
                .eqIfPresent(BusinessCreditDO::getStatus, reqVO.getStatus())
                .betweenIfPresent(BusinessCreditDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(BusinessCreditDO::getId));
    }

    default List<AppBusinessCreditRespVO> appGetBusinessCreditList(){
        return selectJoinList(AppBusinessCreditRespVO.class,new MPJLambdaWrapperX<BusinessCreditDO>()
                .eqIfPresent(BusinessCreditDO::getStatus, CommonStatusEnum.ENABLE.getStatus())
                .neIfPresent(BusinessCreditDO::getPrice, BigDecimal.ZERO)
                .orderByAsc(BusinessCreditDO::getPrice));
    }

}
